home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / viewteamschedule.rexx < prev   
OS/2 REXX Batch file  |  1999-11-29  |  10KB  |  335 lines

  1. /* Mode=Set */
  2. /* ***********************************************************************
  3.  
  4.    VIEW TEAM SCHEDULE PROGRAM FOR FOOTBALL REXX SUITE
  5.   ----------------------------------------------------
  6.                    Copyright  Mark Naughton 1997
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       150997   First release.
  12.            151297   Tidied display.
  13.            210499   Added check for no team specified.
  14.            250899   Added error msg for file checks.
  15.  
  16.            141099   Doh! Forgot to localise this script.....
  17.                     Converted to use locale. Some error messages, before
  18.                     reading the locale, will still be in English.
  19.  
  20.  
  21. **************************************************************************
  22.  
  23. Procedure
  24. ---------
  25.  
  26. 1. Check files exist. Read Teams.df datafile and store teams.
  27. 2. If league has not been autoscheduled then give an error and quit.
  28. 3. Search for specified team and if not found, give an error and quit.
  29. 4. Open Teams.sf datafile.
  30. 5. If "Week" or "Date" is found, grab the data and format it for later.
  31. 6. Use selected team against either HOME or AWAY team and if a match that
  32.    has yet to be played is found, display the data.
  33. 7. When the file is finished, print the number of matches and exit...
  34.  
  35. ************************************************************************** */
  36. PARSE ARG league_stuff
  37.  
  38. version      = 1
  39. input_file   = '.df'
  40. input2_file  = '.sf'
  41. title        = '*LEAGUE_NAME='
  42. autosched    = '*AUTOSCHD='
  43. separator    = '*'
  44. teams.       = '???'
  45. counter      = 0
  46. not_played   = '__   __'
  47. months       = "January February March April May June July August September October November December"
  48.  
  49.  
  50. parse var league_stuff league_file search_team
  51. league_file = "Data/" || league_file
  52.  
  53. addlib('rexxsupport.library',0,-30,0)
  54.  
  55. if open(datafile,"Data/Football.locale",'r') then do
  56.    line = readln(datafile)
  57.    locdir = strip(line)
  58.    close(datafile)
  59. end
  60. else do
  61.    say
  62.    say "ERROR :    (ViewTeamSchedule)"
  63.    say
  64.    say "Cannot read 'Data/Football.locale' for the locale settings."
  65.    exit
  66. end
  67.  
  68. dfordir = locdir"Football.locale_data"
  69. locdir = locdir"User/ViewTeamSchedule.data"
  70.  
  71. if open(datafile,"ENV:FootballRXPath",'r') then do
  72.    line = readln(datafile)
  73.    rxdir = strip(line)
  74.    close(datafile)
  75. end
  76. else
  77.    rxdir = "SYS:Rexxc/"
  78.  
  79. if exists(locdir) > 0 then do
  80.   address command rxdir'rx 'locdir
  81.   VarCount = getclip('VarCount')
  82.   do i = 1 to VarCount
  83.     interpret getclip('var.'i)
  84.   end
  85. end
  86. else do
  87.    say
  88.    say "ERROR :    (ViewTeamSchedule)"
  89.    say
  90.    say "Cannot find '"locdir"' to read locale settings."
  91.    exit
  92. end
  93.  
  94. if exists(dfordir) > 0 then do
  95.   address command rxdir'rx 'dfordir
  96.   VarCount = getclip('VarCount')
  97.   do i = 1 to VarCount
  98.     interpret getclip('var.'i)
  99.   end
  100. end
  101. else do
  102.    say
  103.    say "ERROR :    (ViewTeamSchedule)"
  104.    say
  105.    say "Cannot find '"dfordir"' to read date locale settings."
  106.    exit
  107. end
  108.  
  109. if exists(league_file || input_file) = 0  then do
  110.    say
  111.    say vts_error
  112.    say
  113.    say vts_1"'"league_file || input_file"'."
  114.    exit
  115. end
  116.  
  117. if exists(league_file || input2_file) = 0 then do
  118.    say
  119.    say vts_error
  120.    say
  121.    say vts_1"'"league_file || input2_file"'."
  122.    exit
  123. end
  124.  
  125. if search_team = "" then do
  126.    say
  127.    say vts_error
  128.    say
  129.    say vts_4
  130.    say
  131.    say vts_5" "vts_9
  132.    say
  133.    exit
  134. end
  135.  
  136. autos = 0
  137. if open(datafile,league_file || input_file,'r') then do
  138.    do while ~eof(datafile)
  139.       line = readln(datafile)
  140.       if pos(title,line) > 0 then
  141.          league_title = delstr(line,1,13)
  142.       if pos(autosched,line) > 0 then do
  143.          autofile = delstr(line,1,10)
  144.          autos = 1
  145.       end
  146.       if pos(separator,line) = 0 then do
  147.          line = strip(line)
  148.          if counter = 0 then do
  149.             teams.1 = line
  150.             counter = 1
  151.          end
  152.          else do
  153.             counter       = counter + 1
  154.             teams.counter = line
  155.          end
  156.       end
  157.    end
  158.    close(datafile)
  159. end
  160. else do
  161.    say
  162.    say vts_error
  163.    say
  164.    say vts_2"'"league_file||input_file"'"vts_3
  165.    exit
  166. end
  167.  
  168. if autos = 0 then do
  169.    say
  170.    say vts_error
  171.    say
  172.    say vts_6" '"search_team"'."
  173.    say
  174.    say vts_7
  175.    say vts_8
  176.    say "'Teams6.schd'. "vts_9
  177.    say
  178.    exit
  179. end
  180.  
  181. sel=-1
  182. search_team = strip(search_team)
  183. do i=1 to counter
  184.    if pos(search_team,teams.i) > 0 then
  185.       sel = i
  186. end
  187. if sel > 0 then do
  188.    say
  189.    say center(vts_10" '"league_title"'",78)
  190.    say "-------------------------------------------------------------------------------"
  191.    say
  192.    say vts_11" '"autofile"' "vts_12
  193.    say
  194.    say
  195.    say vts_13": "teams.sel
  196.    say
  197.    say vts_14
  198.    say "----------------------------------------------------"
  199.    say
  200.    matches = 0
  201.    s_l = 0
  202.    if open(datafile,league_file || input2_file,'r') then do
  203.       do while ~eof(datafile)
  204.          line = readln(datafile)
  205.          if pos(separator,line) > 0 then do
  206.             if pos("*Week:",line) > 0 then do
  207.                curr = subword(line,2)
  208.             end
  209.             if pos("*Date:",line) > 0 then do
  210.                if s_l = 0 then do
  211.                   parse var line "*Date:" dateall
  212.                   search_loc = strip(word(dateall,words(dateall)-1))
  213.                   do mnls=1 to 12
  214.                      if pos(word(months,mnls),search_loc) > 0 then do
  215.                         s_l = 1
  216.                         leave
  217.                      end
  218.                   end
  219.                   if s_l = 0 then do
  220.                      locale_cats = showdir("Locale/")
  221.                      do search_locale=1 to words(locale_cats)
  222.                         dfordir = "Locale/"word(locale_cats,search_locale)"/Football.locale_data"
  223.                         if exists(dfordir) > 0 then do
  224.                           address command rxdir'rx 'dfordir
  225.                           VarCount = getclip('VarCount')
  226.                           do i = 1 to VarCount
  227.                             interpret getclip('var.'i)
  228.                           end
  229.                         end
  230.                         parse var line "*Date:" dateall
  231.                         search_loc = strip(word(dateall,words(dateall)-1))
  232.                         do mnls=1 to 12
  233.                            if pos(word(months,mnls),search_loc) > 0 then do
  234.                               s_l = 1
  235.                               leave
  236.                            end
  237.                         end
  238.                         if s_l = 1 then leave
  239.                      end
  240.                   end
  241.                   if s_l > 0 then do
  242.                      temp_dtal = dateall
  243.                      parse var date_format "day" sp1 "number" sp2 "month" sp3 "year"
  244.                      parse var line "*Date:" dateall
  245.                      do i=1 to 7
  246.                         if pos(word(days,i),dateall) > 0 then do
  247.                            lk = pos(word(days,i),dateall)
  248.                            dateall = delstr(dateall,1,lk+length(word(days,i))+length(sp1)-1)
  249.                         end
  250.                      end
  251.                      dateall = strip(dateall)
  252.                      year = word(dateall,words(dateall))
  253.                      mnth = strip(word(dateall,words(dateall)-1))
  254.                      do lm=1 to length(mnth)
  255.                         if datatype(substr(mnth,1,1),'m') ~= 1 then
  256.                            mnth = delstr(mnth,1,1)
  257.                      end
  258.                      dateall = temp_dtal
  259.                      day  = word(dateall,2)
  260.                      do lm=1 to length(day)-2
  261.                         if datatype(substr(day,3,1),'n') ~= 1 then
  262.                            day = delstr(day,3,1)
  263.                      end
  264.                      cv = 0
  265.                      do i=1 to 12
  266.                         if pos(word(months,i),mnth) > 0 then do
  267.                            cv = i
  268.                            leave
  269.                         end
  270.                      end
  271.                   end
  272.                   if s_l = 0 then do
  273.                      say
  274.                      say vts_error
  275.                      say
  276.                      say vts_21
  277.                      exit
  278.                   end
  279.  
  280.                   curr = right(day,2,0)" "substr(word(months,cv),1,3)" "substr(year,3,2)
  281.                   s_l = 0
  282.                end
  283.             end
  284. /*
  285.             if pos("*Date:",line) > 0 then do
  286.                year = word(line,5)
  287.                mnth = word(line,4)
  288.                day  = word(line,3)
  289.                curr = right(day,2,0)" "substr(mnth,1,3)" "substr(year,3,2)
  290.             end
  291. */
  292.          end
  293.          if pos(separator,line) = 0 then do
  294.             if pos(not_played,line) > 0 then do
  295.                home_team = strip(substr(line,1,30))
  296.                away_team = strip(substr(line,41,30))
  297.  
  298.                strng = strip(teams.sel)
  299.                if strng = home_team then do
  300.                   say left(curr,12)""left(vts_15,9,' ')""left(away_team,30)
  301.                   matches = matches + 1
  302.                end
  303.                if strng = away_team then do
  304.                   say left(curr,12)""left(vts_16,9,' ')""left(home_team,30)
  305.                   matches = matches + 1
  306.                end
  307.             end
  308.          end
  309.       end
  310.       close(datafile)
  311.       say
  312.       if matches = 0 then
  313.          say vts_17
  314.       else
  315.          say vts_18":  "matches
  316.       say
  317.       say "-------------------------------------------------------------------------------"
  318.       say
  319.    end
  320.    else do
  321.       say
  322.       say vts_error
  323.       say
  324.       say vts_2"'"league_file || input2_file"'"vts_3
  325.       exit
  326.    end
  327. end
  328. else do
  329.    say
  330.    say vts_error
  331.    say
  332.    say vts_19" '"search_team"' "vts_20
  333. end
  334.  
  335. exit